home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc1_2_x / rtfmaker.sit / RTF Maker / card_3067.txt < prev    next >
Text File  |  1990-02-06  |  11KB  |  349 lines

  1. -- card: 3067 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2747
  5. -- name: 
  6.  
  7.  
  8. -- part 14 (button)
  9. -- low flags: 00
  10. -- high flags: A000
  11. -- rect: left=406 top=164 right=221 bottom=502
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 1 / 1
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Further Info
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   show cd fld moreInfo
  23. end mouseUp
  24.  
  25.  
  26.  
  27. -- part 12 (button)
  28. -- low flags: 00
  29. -- high flags: A000
  30. -- rect: left=406 top=94 right=151 bottom=502
  31. -- title width / last selected line: 0
  32. -- icon id / first selected line: 20965 / 20965
  33. -- text alignment: 1
  34. -- font id: 0
  35. -- text size: 12
  36. -- style flags: 0
  37. -- line height: 16
  38. -- part name: About RTF Maker
  39. ----- HyperTalk script -----
  40. on mouseUp
  41.   ShowDialog 1,300,"",False,1,8
  42. end mouseUp
  43.  
  44.  
  45.  
  46. -- part 9 (button)
  47. -- low flags: 00
  48. -- high flags: 8004
  49. -- rect: left=166 top=21 right=41 bottom=238
  50. -- title width / last selected line: 0
  51. -- icon id / first selected line: 0 / 0
  52. -- text alignment: 1
  53. -- font id: 0
  54. -- text size: 12
  55. -- style flags: 0
  56. -- line height: 16
  57. -- part name: RTF Style
  58. ----- HyperTalk script -----
  59.  
  60.  
  61. on mouseDown
  62.   put ",b,i,ul,up6\fs18,dn6\fs18,outl,shad,scaps,caps,v,strike,ulw,uldb,uld" into RTFlist
  63.   get PopUp ("┬⌐1988SDrazga",160,rect of me)
  64.   if it is 0 then exit mouseDown
  65.   if the selection is empty then exit mouseDown
  66.   put it into styleNo
  67.   if StyleNo is 1 then
  68.     removeFormats
  69.     exit mouseDown
  70.   end if
  71.   if it is 0 then exit mouseDown
  72.   put item styleNo of RTFlist into RTFSymb
  73.   addFormat RTFSymb
  74. end mouseDown
  75.  
  76.  
  77.  
  78. -- part 2 (field)
  79. -- low flags: 00
  80. -- high flags: 0007
  81. -- rect: left=31 top=73 right=335 bottom=377
  82. -- title width / last selected line: 0
  83. -- icon id / first selected line: 0 / 0
  84. -- text alignment: 0
  85. -- font id: 3
  86. -- text size: 12
  87. -- style flags: 0
  88. -- line height: 16
  89. -- part name: theText
  90.  
  91.  
  92. -- part 4 (button)
  93. -- low flags: 00
  94. -- high flags: 2000
  95. -- rect: left=0 top=318 right=342 bottom=33
  96. -- title width / last selected line: 0
  97. -- icon id / first selected line: 1011 / 1011
  98. -- text alignment: 1
  99. -- font id: 0
  100. -- text size: 12
  101. -- style flags: 0
  102. -- line height: 16
  103. -- part name: Go Home
  104. ----- HyperTalk script -----
  105. on mouseUp
  106.   Go Home
  107. end mouseUp
  108.  
  109.  
  110.  
  111. -- part 5 (button)
  112. -- low flags: 00
  113. -- high flags: A004
  114. -- rect: left=66 top=20 right=71 bottom=144
  115. -- title width / last selected line: 0
  116. -- icon id / first selected line: 200 / 200
  117. -- text alignment: 1
  118. -- font id: 0
  119. -- text size: 12
  120. -- style flags: 0
  121. -- line height: 16
  122. -- part name: Make RTF File
  123. ----- HyperTalk script -----
  124. on mouseUp
  125.   get NewFileName("Name of new RTF file", "New.RTF")
  126.   if it is empty then exit mouseUp
  127.   set cursor to 4
  128.   put it into theFile
  129.   open file theFile
  130.   put cd fld theText into tex
  131.   repeat      -- replace CR's with \par
  132.     put offset (return, tex) into theRet
  133.     if theRet is 0 then exit repeat
  134.     put "\par " into char theRet of tex
  135.   end repeat
  136.   write (cd fld RTFheader) to file theFile
  137.   write tex to file theFile
  138.   write "}" to file theFile
  139.   close file theFile
  140.   get ChangeFileType (theFile, "TEXT", "MSWD")
  141. end mouseUp
  142.  
  143.  
  144.  
  145. -- part 6 (button)
  146. -- low flags: 00
  147. -- high flags: 8004
  148. -- rect: left=236 top=21 right=41 bottom=310
  149. -- title width / last selected line: 0
  150. -- icon id / first selected line: 0 / 0
  151. -- text alignment: 1
  152. -- font id: 0
  153. -- text size: 12
  154. -- style flags: 0
  155. -- line height: 16
  156. -- part name: Font
  157. ----- HyperTalk script -----
  158. on mouseDown
  159.   get the selectedChunk
  160.   put it into theSel
  161.   get PopUp ("┬⌐1988SDrazga",201,rect of me,x)
  162.   if it is empty then exit mouseDown
  163.   put it into fontName
  164.   if the selection is empty then exit mouseDown
  165.   find whole it in bg fld fontList
  166.   put the foundLine into theLine
  167.   if theLine is empty then
  168.     put "Can't find" && fontName
  169.   else
  170.     get theLine
  171.     put "f" & first word of the value of theLine into theFont
  172.     select theSel
  173.     addFormat theFont
  174.   end if
  175. end mouseDown
  176.  
  177.  
  178.  
  179. -- part 7 (button)
  180. -- low flags: 00
  181. -- high flags: 8004
  182. -- rect: left=308 top=21 right=41 bottom=382
  183. -- title width / last selected line: 0
  184. -- icon id / first selected line: 0 / 0
  185. -- text alignment: 1
  186. -- font id: 0
  187. -- text size: 12
  188. -- style flags: 0
  189. -- line height: 16
  190. -- part name: Size
  191. ----- HyperTalk script -----
  192. function doOther
  193. ShowDialog 2,200,"","","","",1,1
  194. get the result
  195. return it
  196. end doOther
  197.  
  198. on mouseDown
  199.   get PopUp ("┬⌐1988SDrazga",220,rect of me,x)
  200.   if the selection is empty then exit mouseDown
  201.   if it is empty then exit mouseDown
  202.   put it into choice
  203.   if offset("Other", choice) > 0 then put doOther() into choice
  204.   if choice + 0 <= 0 then exit mouseDown
  205.   put "fs" & (choice * 2) into theSize
  206.   addFormat theSize
  207. end mouseDown
  208.  
  209.  
  210.  
  211. -- part 1 (field)
  212. -- low flags: 80
  213. -- high flags: 0007
  214. -- rect: left=277 top=48 right=149 bottom=510
  215. -- title width / last selected line: 0
  216. -- icon id / first selected line: 0 / 0
  217. -- text alignment: 0
  218. -- font id: 3
  219. -- text size: 9
  220. -- style flags: 0
  221. -- line height: 12
  222. -- part name: RTFHeader
  223. ----- HyperTalk script -----
  224. On mouseUp
  225.   hide me
  226. end mouseUp
  227.  
  228.  
  229. -- part 3 (button)
  230. -- low flags: 00
  231. -- high flags: A000
  232. -- rect: left=410 top=25 right=45 bottom=507
  233. -- title width / last selected line: 0
  234. -- icon id / first selected line: 0 / 0
  235. -- text alignment: 1
  236. -- font id: 0
  237. -- text size: 12
  238. -- style flags: 0
  239. -- line height: 16
  240. -- part name: Show Data
  241. ----- HyperTalk script -----
  242. on mouseUp
  243.   if the short name of me is "Show Data" then
  244.     set the name of me to "Hide Data"
  245.     Show cd fld RTFheader
  246.     show bg fld fontList
  247.   else
  248.     hide cd fld RTFheader
  249.     hide bg fld fontList
  250.     set the name of me to "Show Data"
  251.   end if
  252. end mouseUp
  253.  
  254.  
  255.  
  256. -- part 16 (field)
  257. -- low flags: 81
  258. -- high flags: 0007
  259. -- rect: left=0 top=19 right=338 bottom=512
  260. -- title width / last selected line: 0
  261. -- icon id / first selected line: 0 / 0
  262. -- text alignment: 0
  263. -- font id: 3
  264. -- text size: 12
  265. -- style flags: 0
  266. -- line height: 16
  267. -- part name: moreInfo
  268. ----- HyperTalk script -----
  269. on mouseUp
  270.   hide me
  271. end mouseUp
  272.  
  273.  
  274. -- part contents for card part 1
  275. ----- text -----
  276. {\rtf0\mac {\fonttbl{\f0\fswiss Chicago;}{\f2\froman New York;}{\f3\fswiss Geneva;}{\f4\fmodern Monaco;}{\f5\fscript Venice;}{\f6\fdecor London;}{\f13\fnil Princeton;}{\f14\fnil Bookman;}{\f15\fnil N Helvetica Narrow;}{\f16\fnil Palatino;}
  277. {\f18\fnil Zapf Chancery;}{\f20\froman Times;}{\f21\fswiss Helvetica;}{\f22\fmodern Courier;}{\f23\ftech Symbol;}{\f33\fnil Avant Garde;}{\f34\fnil New Century Schlbk;}{\f128\fnil B-New York;}{\f129\fnil Zapf Dingbats;}{\f193\fnil L Helvetica Light;}
  278. {\f200\fnil MF Symbols;}{\f203\fnil NY 48|72;}{\f230\fnil Alison;}}{\stylesheet{\f20\fs28 \sbasedon222\snext0 Normal;}}\widowctrl\ftnbj\ftnrestart \sectd \linemod0\linex0\cols1\colsx0\endnhere \pard\plain \f20\fs28 
  279.  
  280. -- part contents for card part 2
  281. ----- text -----
  282.  
  283.                         RTF Maker
  284.  
  285.  
  286. This stack demonstrates how you can use HyperCard to produce fully formatted Microsoft WordΓäó documents.  This is often useful if you need to print data from HyperCard using various fonts, styles and sizes. 
  287.  
  288. The method makes use of Word's "rich text format", or RTF.  Embedded code characters such as \ and are used to indicate font, size, and style information.
  289.  
  290. To try it out, simply select text in this field and choose from the style, font and size menus above.  When you do, the special RTF code symbols will be placed around your selected text.
  291.  
  292. Here is a sample:
  293.  
  294.      This sentence is in Helvetica 18 point font, with some italics, some boldface, some outline-italic, some {\uldb double-underline text.
  295.  
  296. Then hit the "Make RTF File" button to create a Word document.  When you double-click on this document to invoke Word you will be asked if you wish to interpret the RTF code.  You should answer YES.  
  297.  
  298. You can use this stack as is, or you can take it as a demonstration of how to do the same thing in your own stacks.  If you want to put this capability into other stacks, be sure to move the MENU and XFCN {\b {\fs28 {\f16 resources that go with it.  Also, there are two hidden data fields (you can see them by clicking the "Show Data" button).  These contain information needed in the file's header and also the ID numbers of the various fonts.}}}
  299.  
  300. If you use this stuff in your own stack, be sure to acknowledge the authors of the XFCNs and XCMDs that are used (see "About RTF Maker").  And of course, yours truly.
  301.  
  302.                                  Bill Engels
  303.  
  304.  
  305.  
  306.  
  307. -- part contents for background part 1
  308. ----- text -----
  309. 33 Avant Garde
  310. 14 Bookman
  311. 0 Chicago
  312. 22 Courier
  313. 3 Geneva
  314. 21 Helvetica
  315. 6 London
  316. 4 Monaco
  317. 15 N Helvetica Narrow
  318. 34 New Century Schlbk
  319. 2 New York
  320. 16 Palatino
  321. 13 Princeton
  322. 23 Symbol
  323. 20 Times
  324. 5 Venice
  325. 18 Zapf Chancery
  326. 129 Zapf Dingbats
  327.  
  328.  
  329. -- part contents for card part 16
  330. ----- text -----
  331.  
  332.                                          Further Information
  333.                                        --------------------
  334.  
  335.       Word's RTF is just a plain text file with a special header defining the fonts, stylesheets, etc. that are used in the body of the text.  When Word opens the file and detects the special code characters in the header, it interprets the body of the text (at your option) as an RTF file.  The formatting codes always include the backslash (\) character and terminate with a space.
  336.  
  337.        There is a lot more that can be done in RTF than this little example demonstrates.  For example, I haven't included any ruler information, graphics or stylesheet options in this stack.  These things shouldn't be too hard to add if you need them.  
  338.  
  339.      It's easy to discover the RTF codes for yourself just by setting up a document in Word 3.0, then saving it as RTF.  Just select "Save As ΓǪ" from the File menu and click on the Format button.  Then choose
  340.                 "Interchange Format (RTF)"
  341.  
  342. After you save the file, the rather messy looking RTF information will be on your screen for you to examine.  The full header will also be there.  If you want to use a different header from the one I have provided, simply copy your own RTF header and paste it into the "RTFheader" field.
  343.  
  344.      At the time of this writing version 4.0 of Word is not available.  Therefore, I cannot say whether RTF will continue to be supported or whether it will undergo changes.  However, since the purpose of RTF is for exchanging files with other word processing programs (mainly versions of Word on blue computers), it seems unlikely that the format will be abandoned anytime soon.
  345.  
  346.                             Bill Engels
  347.                             19 November 1988
  348.     
  349.